import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pandas_profiling import ProfileReport
earthquakes = pd.read_csv('all_month.csv')
earthquakes.head()
| time | latitude | longitude | depth | mag | magType | nst | gap | dmin | rms | ... | updated | place | type | horizontalError | depthError | magError | magNst | status | locationSource | magSource | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2021-11-25T02:22:39.990Z | 33.665833 | -116.775667 | 14.430000 | 0.98 | ml | 38.0 | 45.000000 | 0.068370 | 0.230000 | ... | 2021-11-25T02:26:24.796Z | 10km SSW of Idyllwild, CA | earthquake | 0.30000 | 0.520000 | 0.218 | 28.0 | automatic | ci | ci |
| 1 | 2021-11-25T02:18:47.640Z | 38.564999 | -119.455498 | 2.500000 | 2.11 | md | 9.0 | 83.000000 | 0.054610 | 0.080000 | ... | 2021-11-25T02:26:11.519Z | 6km NNE of Walker, CA | earthquake | 0.50000 | 1.450000 | 0.130 | 8.0 | automatic | nc | nc |
| 2 | 2021-11-25T02:16:05.228Z | 36.368938 | -97.340614 | 2.847088 | 2.34 | ml | 45.0 | 55.237244 | 0.091238 | 0.567835 | ... | 2021-11-25T02:18:42.143Z | 9 km NNW of Perry, Oklahoma | earthquake | 1.77366 | 1.334918 | NaN | 34.0 | automatic | ok | ok |
| 3 | 2021-11-25T02:04:54.180Z | 19.188499 | -155.487167 | 30.600000 | 1.72 | ml | 45.0 | 76.000000 | NaN | 0.130000 | ... | 2021-11-25T02:10:24.830Z | 1 km SSW of Pāhala, Hawaii | earthquake | 0.63000 | 0.910000 | 4.970 | 3.0 | automatic | hv | hv |
| 4 | 2021-11-25T01:57:27.020Z | 33.490500 | -116.785167 | 3.350000 | 1.38 | ml | 57.0 | 32.000000 | 0.025230 | 0.200000 | ... | 2021-11-25T02:08:35.040Z | 9km NE of Aguanga, CA | earthquake | 0.20000 | 0.580000 | 0.179 | 27.0 | automatic | ci | ci |
5 rows × 22 columns
profile = ProfileReport(earthquakes, title="Pandas Profiling Report")
profile
fig1, ax = plt.subplots()
earthquakes.boxplot(column='mag', ax=ax)
<AxesSubplot:>
fig2, ax = plt.subplots()
earthquakes.hist(column='mag', ax=ax, bins=75, color='green', label='Magnitude') #bins is the number of uppy bars
ax.set_title('Distrubution of Magnitude') #adds title
ax.set_ylabel('Quantity') #adds axis label
ax.set_xlabel('Earthquake magnitude')
ax.legend()
<matplotlib.legend.Legend at 0x14e2a864250>
fig3, ax = plt.subplots()
ax.scatter(earthquakes['depth'],earthquakes['mag'], 40, alpha=0.4, marker='+')
ax.set_title('Magnitude vs Depth') #adds title
ax.set_ylabel('Magnitude') #adds axis label
ax.set_xlabel('Depth(km)')
Text(0.5, 0, 'Depth(km)')
fig4, ax = plt.subplots()
ax.scatter(earthquakes['depth'],earthquakes['mag'], 40, alpha=0.4, marker='+')
plt.xlim(-25, 75)
ax.set_title('Magnitude vs Depth') #adds title
ax.set_ylabel('Magnitude') #adds axis label
ax.set_xlabel('Depth(km)')
Text(0.5, 0, 'Depth(km)')
fig5, ax = plt.subplots()
ax.scatter(earthquakes['depth'],earthquakes['mag'], 40, alpha=0.4, marker='+')
plt.ylim(3.75, 6)
ax.set_title('Magnitude vs Depth') #adds title
ax.set_ylabel('Magnitude') #adds axis label
ax.set_xlabel('Depth(km)')
Text(0.5, 0, 'Depth(km)')
fig6, ax = plt.subplots()
ax.scatter(earthquakes['depth'],earthquakes['mag'], 40, alpha=0.4, marker='+')
plt.xlim(200, 700)
ax.set_title('Magnitude vs Depth') #adds title
ax.set_ylabel('Magnitude') #adds axis label
ax.set_xlabel('Depth(km)')
Text(0.5, 0, 'Depth(km)')
import seaborn as sns
fig7, ax = plt.subplots()
sns.regplot(earthquakes['depth'],earthquakes['mag'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('Magnitude vs Depth') #adds title
ax.set_ylabel('Magnitude') #adds axis label
ax.set_xlabel('Depth(km)')
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'Depth(km)')
fig8, ax = plt.subplots()
sns.regplot(earthquakes['depth'],earthquakes['dmin'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('dmin vs Depth') #adds title
ax.set_ylabel('dmin') #adds axis label
ax.set_xlabel('Depth(km)')
#shallower earthquakes are sometimes picked up with the closest montoring stations quite far away
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'Depth(km)')
eq_deep = earthquakes[earthquakes['depth']>250]
fig9, ax = plt.subplots()
sns.regplot(eq_deep['depth'],eq_deep['dmin'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('dmin vs Depth') #adds title
ax.set_ylabel('dmin') #adds axis label
ax.set_xlabel('Depth(km)')
#
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'Depth(km)')
fig10, ax = plt.subplots()
sns.regplot(earthquakes['mag'], earthquakes['dmin'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('dmin vs magnitude') #adds title
ax.set_ylabel('dmin') #adds axis label
ax.set_xlabel('Magnitude')
#bigger magnitude earthquakes are sometimes picked up with the closest montoring stations quite far away
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'Magnitude')
fig11, ax = plt.subplots()
sns.regplot(eq_deep['mag'],eq_deep['dmin'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('dmin vs magnitude') #adds title
ax.set_ylabel('dmin') #adds axis label
ax.set_xlabel('Magnitude')
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'Magnitude')
fig12, ax = plt.subplots()
ax = plt.axes(projection ="3d")
ax.scatter3D(eq_deep['depth'],eq_deep['dmin'], eq_deep['mag'])
ax.set_ylabel('dmin') #adds axis label
ax.set_xlabel('Depth')
ax.set_zlabel('Magnitude')
Text(0.5, 0, 'Magnitude')
fig13, ax = plt.subplots()
sns.regplot(earthquakes['mag'], earthquakes['nst'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('nst vs magnitude') #adds title
ax.set_ylabel('nst') #adds axis label
ax.set_xlabel('Magnitude')
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'Magnitude')
fig14, ax = plt.subplots()
ax.scatter(earthquakes['depth'], earthquakes['nst'], 40, alpha=0.4, marker='+')
ax.set_title('nst vs depth') #adds title
ax.set_ylabel('nst') #adds axis label
ax.set_xlabel('depth')
Text(0.5, 0, 'depth')
fig15, ax = plt.subplots()
sns.regplot(earthquakes['dmin'], earthquakes['nst'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('nst vs dmin') #adds title
ax.set_ylabel('nst') #adds axis label
ax.set_xlabel('dmin')
#the further the nearest station to detect it, the fewer stations that record it
C:\Users\matt_\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
Text(0.5, 0, 'dmin')
#no idea why this dooesn't work...
fig16, ax = plt.subplots()
sns.regplot(eq_deep['nst'],eq_deep['depth'], marker='+',scatter_kws={"alpha":0.4})
ax.set_title('depth vs nst')
ax.set_ylabel('depth')
ax.set_xlabel('nst')
Text(0.5, 0, 'nst')
fig17, ax = plt.subplots()
ax.scatter(earthquakes['depth'], earthquakes['nst'], 40, marker='+')
ax.set_ylim(0,50)
ax.set_xlim(100,250)
ax.set_title('nst vs depth') #adds title
ax.set_ylabel('nst') #adds axis label
ax.set_xlabel('depth')
#lots of nst data missing for deep quakes...
Text(0.5, 0, 'depth')
fig18, ax = plt.subplots()
earthquakes.boxplot(column='depth', ax=ax)
<AxesSubplot:>
fig1.savefig('boxmag.jpg')
fig2.savefig('histmag.jpg')
fig3.savefig('magdep.jpg')
fig4.savefig('mdshal.jpg')
fig5.savefig('mdbig.jpg')
fig6.savefig('mddeep.jpg')
fig7.savefig('mdline.jpg')
fig8.savefig('dminDepth.jpg')
fig9.savefig('dminDepthDeep.jpg')
fig10.savefig('dminMag.jpg')
fig11.savefig('dminMagDeep.jpg')
fig12.savefig('3dDeep.jpg')
fig13.savefig('mstMag.jpg')
fig14.savefig('nstDepth.jpg')
fig15.savefig('nstDmin.jpg')
fig17.savefig('nstDepthZoom.jpg')
fig18.savefig('boxDepth.jpg')